package com.qf.boot2302.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import java.io.IOException;

@Slf4j
public class CheckPasswordFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("==============CheckPasswordFilter 开始工作===============");
        // 让请求就此打住
        String password = request.getParameter("password");
        if (password==null){
            log.info("必传参数 password 为null了");
            response.setContentType("text/html;charset=utf-8");
            response.getWriter().println("必传参数 password 为空");
        }else {
            // 放行该请求
            chain.doFilter(request,response);
            System.out.println("==============CheckPasswordFilter 结束工作了===============");
        }
    }
}
